package com.qdlc.p2p.dal.model;

import java.util.Calendar;
import java.util.Date;

import com.qdlc.p2p.dal.dto.ArticleRank;

/**
 * Created by liaoxiangkai on 2016/1/11.
 */
public class ArticleRankModel extends ArticleRank {

    //返回true不是本周，返回false是本周
    public static boolean isThisWeek(Date modifyTime){
        Calendar c = Calendar.getInstance();
        int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
        if (day_of_week == 0)
            day_of_week = 7;
        c.add(Calendar.DATE, -day_of_week + 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.MILLISECOND, 0);
        return modifyTime.before(c.getTime());
    }

    //判断是不是本月,true不是本月，false是本月
    public static boolean isThisMonth(Date modifyTime) {
        Calendar c = Calendar.getInstance();
        //得到一个月第一天
        int MaxDay=c.getActualMinimum(Calendar.DAY_OF_MONTH);
        c.set( c.get(Calendar.YEAR), c.get(Calendar.MONTH), MaxDay, 0, 0, 0);
        return modifyTime.before(c.getTime());
    }
}
